//
//  HESpeechListener.h
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/24.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Speech/Speech.h>

NS_ASSUME_NONNULL_BEGIN


typedef void(^speakToTextBlock)(NSString *text, BOOL status);

API_AVAILABLE(ios(10.0))
@interface HESpeechListener : NSObject
<SFSpeechRecognitionTaskDelegate,SFSpeechRecognizerDelegate>

@property(nonatomic,strong) SFSpeechRecognizer *listener;
@property(nonatomic,strong) SFSpeechRecognitionTask *recognitionTask;
@property(nonatomic,assign) SFSpeechRecognizerAuthorizationStatus authorizationStatus;
@property(nonatomic,strong) SFSpeechAudioBufferRecognitionRequest *recognitionRequest;
@property(nonatomic,assign) BOOL inRecognizer;

@property(nonatomic,copy) void (^haveRecognizerSpeakTextBlock)(NSString *text, NSTimeInterval startLocation, NSTimeInterval length);

@property(nonatomic, copy) speakToTextBlock textBlock;

+ (instancetype)sharedManager;

-(void)startRecognizer;

-(void)giveBuffer:(CMSampleBufferRef)buffer;

-(void)endRecognizer;

@end

NS_ASSUME_NONNULL_END
